﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Security;

namespace Interfaces.CronogramaDeActividades
{
    public partial class VerCronogramaDeActvidades : System.Web.UI.Page
    {
        string res;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
                FormsAuthentication.RedirectToLoginPage();
            if (GridView1.Rows.Count == 0)
                Label2.Text = "Ingrese una Gestion";
            else
                Label2.Text = "" ;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (TextBox2.Text != "")
            {
                if (Convert.ToInt32(TextBox2.Text) > 1966)
                {
                    try
                    {
                        Label2.Text = "";
                        string CI = Convert.ToString(DataBase.Miembro2.BDMiembro.DevolverMiembroPorUsuario(User.Identity.Name).CI);// "121212";
                        int Gestion = Convert.ToInt32(TextBox2.Text);
                        DataSet lista = Processes.CronogramaDeActividades.GestorCronogramaActividades.ObtenerListaActividades(CI, Gestion);
                        GridView1.DataSource = lista;   
                        GridView1.DataBind();
                        if (GridView1.Rows.Count == 0)
                            Label2.Text = "Usted no tiene actividades en esta gestion.";
                        else
                            Label2.Text = "";
                    }
                    catch (Exception expetion)
                    {
                        throw expetion;
                    }
                }
                else
                {
                    Label2.Text = "*Gestion invalida, las gestiones son a partir de 1967";
                }
            }
            else
            {
                Label2.Text = "*Debe Introducir una gestion";
            }
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["BuscarMaster"] != null)
            {
                res = (string)Session["BuscarMaster"];
                this.MasterPageFile = res;
            }
        }

    }
}